<?
include("./_common.php");
include("$g4[path]/_head.php");

$shop = get_shop();
$goods_dir = $g4[path]."/data/goods/";
$CART = explode("/",$_SESSION["g4_cart"]);

?>
<link rel="stylesheet" href="<?=$g4['path']?>/shop/style.css" type="text/css">
<script language="javascript" src="<?=$g4['path']?>/shop/shop.js"></script>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<form name="order_step2" method="post" action="order_step3.php">
<input type="hidden" name="mb_id" value="<?=$member[mb_id]?>">
<input type="hidden" name="mb_part" value="<?if($member[mb_id]){echo("member");}else{echo("guest");}?>">
<input type="hidden" name="o_name" value="<?=$o_name?>">
<input type="hidden" name="o_email" value="<?=$o_email?>">
<input type="hidden" name="o_tel" value="<?=$o_tel?>">
<input type="hidden" name="o_hp" value="<?=$o_hp?>">
<input type="hidden" name="o_zip" value="<?=$o_zip1."-".$o_zip2?>">
<input type="hidden" name="o_addr1" value="<?=$o_addr1?>">
<input type="hidden" name="o_addr2" value="<?=$o_addr2?>">
<input type="hidden" name="s_name" value="<?=$s_name?>">
<input type="hidden" name="s_email" value="<?=$s_email?>">
<input type="hidden" name="s_tel" value="<?=$s_tel?>">
<input type="hidden" name="s_hp" value="<?=$s_hp?>">
<input type="hidden" name="s_zip" value="<?=$s_zip1."-".$s_zip2?>">
<input type="hidden" name="s_addr1" value="<?=$s_addr1?>">
<input type="hidden" name="s_addr2" value="<?=$s_addr2?>">
<input type="hidden" name="s_memo" value="<?=$s_memo?>">
	<tr>
		<td>
		<table cellpadding="0" cellspacing="1" border="0" width="100%" style="border:solid 1px #CCCCCC">
			<tr align="center" height="20">
				<td bgcolor="#EFEFEF">상품명</td>
				<td bgcolor="#EFEFEF" width="100">옵션</td>
				<td bgcolor="#EFEFEF" width="80">수량</td>
				<td bgcolor="#EFEFEF" width="80">단가</td>
				<td bgcolor="#EFEFEF" width="80">합계금액</td>
			</tr>
		</table>
		<?
		if(trim($_SESSION["g4_cart"]))
		{
			$tot_price = 0;
			$tot_tranc = $shop[tranc_price];
			$lineCnt = 0;
			for($i=0;$i<count($CART);$i++)
			{
				$tmpField = explode("|",$CART[$i]);
				$tmpGcode = explode("OP",$tmpField[0]);
				$goods = get_goods($tmpGcode[0]);
				$g_option = get_option($goods[g_option],$tmpGcode[1]);
		?>
		<DIV style="width:100%;height:50px;float:left;padding:5 0 5 0;border-bottom:solid 1px #D7D7D7">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="50" style="table-layout:fixed">
			<tr>
				<td width="50" rowspan="2"><img src="<?=$goods_dir.$goods[g_img1]?>" width="50" height="50"></td>
				<td width="10" rowspan="2"></td>
				<td>
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td><a href="<?=$goods[href]?>"><b><?=$goods[g_name]?></b></a><br><span style="color:orange"><?=$goods[g_info]?></span></td>
							<td width="100" align="center"><?=$g_option[0]?></td>
							<td width="80" align="center">
							<?=$tmpField[1]?>EA<br>
							</td>
							<td width="80" align="center"><span style="color:#990000"><?=number_format($goods[g_price]+$g_option[1])?>원</span></td>
							<td width="80" align="center"><span style="color:#990000"><b><?=number_format(($goods[g_price]+$g_option[1]) * $tmpField[1])?>원</b></span></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td><span class="subinfo1">제조/판매원&nbsp;:&nbsp;<?=$goods[g_create]?></span>&nbsp;|&nbsp;<span class="subinfo2">원산지&nbsp;:&nbsp;<?=$goods[g_nation]?></span>&nbsp;|&nbsp;<span class="subinfo3">배송료&nbsp;:&nbsp;<?=$goods[tranc]?></span></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</DIV>
		<?
				$tot_price+= ($goods[g_price] + $g_option[1]) * $tmpField[1];
				if($tot_price >= $shop[tranc_if] || $goods[g_tranc] == "N" || $goods[g_tranc] == "C")
				{
					$tot_tranc = 0;
				}
				$lineCnt++;
			}
		}

		if($lineCnt==0)
		{
			echo("<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100'><tr align='center'><td>장바구니에 상품이 없습니다.</td></tr></table>");
		}
		?>
		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#EFEFEF">
				<tr align="right" height="30">
					<td>배송비 : <?=number_format($tot_tranc)?>원</td>
					<td>총구매금액 : <?=number_format($tot_price)?>원</td>
				</tr>
				<tr align="right" height="30">
					<td colspan="2"><span style="color:#990000;font-size:16px;font-weight:bold">총금액 : <?=number_format($tot_tranc + $tot_price)?>원</span></td>
				</tr>
			</table>
		<tr>
	</tr>
	<tr>
		<td height="20"></td>
	</tr>
	<tr>
		<td valign="top">
		<?
		if($member[mb_id] && $shop[point_use]=="Y")
		{
		?>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td><span class="orderTabTitle">포인트 결제</span></td>
				</tr>
				<tr>
					<td>
						<table cellpadding="5" cellspacing="0" border="0" width="100%" style="border:solid 1px #D7D7D7">
							<tr>
								<td class="orderIndex">보유포인트</td>
								<td><input type="text" class="ed" style="width:80px;text-align:right;border:none" readonly name="my_point" value="<?=number_format($member[mb_point])?>">점&nbsp;(<?=number_format($shop[point_price])?>점 부터 결제가능)</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="orderIndex">결제포인트</td>
								<td><input type="text" class="ed" style="width:80px;text-align:right" name="use_point" value="0" <?if($shop[point_price] > $member[mb_point]){echo("readonly");}?>>점 <button class="cart_btn2" style="width:80px" onclick="PointUse()">포인트결제</button></td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="orderIndex">결제후포인트</td>
								<td><input type="text" class="ed" style="width:80px;text-align:right;border:none" readonly name="end_point" value="<?=number_format($member[mb_point])?>">점</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<br><br>
		<?
		}
		?>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td><span class="orderTabTitle">결제하기</span></td>
				</tr>
				<tr>
					<td>
						<table cellpadding="5" cellspacing="0" border="0" width="100%" style="border:solid 1px #D7D7D7">
							<tr>
								<td class="orderIndex">총주문금액</td>
								<td><input type="text" name="pay_price" readonly style="width:120px;text-align:right;border:none" value="<?=number_format($tot_price)?>">원</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="orderIndex">배송비</td>
								<td><input type="text" name="pay_tranc" readonly style="width:120px;text-align:right;border:none" value="<?=number_format($tot_tranc)?>">원</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="orderIndex">결제포인트</td>
								<td><input type="text" name="pay_point" readonly style="width:120px;text-align:right;border:none" value="0">원</td>
							</tr>
							<tr><td colspan="2" height="1" bgcolor="#D7D7D7"></td></tr>
							<tr>
								<td class="orderIndex">결제금액</td>
								<td><input type="text" name="pay_amount" readonly style="width:120px;text-align:right;border:none;font-size:14px;font-weight:bold;color:#990000" value="<?=number_format($tot_price + $tot_tranc)?>"><span style="font-size:14px;font-weight:bold;color:#990000">원</span></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="20"></td>
				</tr>
				<tr>
					<td><span class="orderTabTitle">결제선택</span></td>
				</tr>
				<tr>
					<td>
						<table cellpadding="5" cellspacing="0" border="0" width="100%" style="border:solid 1px #D7D7D7">
							<tr>
								<td bgcolor="#EFEFEF">
								<?if($shop[card_use]=="Y"){?>
								<input type="radio" name="pay_method" value="card" onclick="PayMethodShow('normal');">신용카드<?}?>
								<?if($shop[iche_use]=="Y"){?>
								<input type="radio" name="pay_method" value="iche" onclick="PayMethodShow('iche');">자동이체
								<?}?>
								<?if($shop[hp_use]=="Y"){?>
								<input type="radio" name="pay_method" value="hp" onclick="PayMethodShow('normal');">휴대폰결제
								<?}?>
								<?if($shop[ebank_use]=="Y"){?>
								<input type="radio" name="pay_method" value="ebank" onclick="PayMethodShow('normal');">가상계좌
								<?}?>
								<?if($shop[bank_use]=="Y"){?>
								<input type="radio" name="pay_method" value="bank" onclick="PayMethodShow('bank');">무통장
								<?}?>
								</td>
							</tr>
							<tr>
								<td>
									<table cellpadding="3" border="0" border="0" id="normal" style="display:none">
										<tr>
											<td>
											결제자명 : <input type="text" class="ed" style="width:120px" name="pay_user">
											</td>
										</tr>
									</table>
									<table cellpadding="3" border="0" border="0" id="iche" style="display:none">
										<tr>
											<td>
											결제자명 : <input type="text" class="ed" style="width:120px" name="pay_iche_user"><br>
											주민번호 : <input type="text" class="ed" style="width:60px" name="pay_pid1"> - <input type="text" class="ed" style="width:70px" name="pay_pid2"><br>
											※<span style="color:#888888;font-size:11px"> 자동이체시 주민번호는 필수사항 입니다.</span>
											</td>
										</tr>
									</table>
									<table cellpadding="3" cellspacing="0" border="0" id="bank" style="display:none">
										<tr>
											<td>입금계좌 : 
											<select name="bank_info" style="font-family:굴림;font-size:11px">
												<option value="">입금계좌를 선택하여 주십시오.</option>
											<?
											$tmp_bank_record = explode("/",$shop[bank_info]);
											for($i=0;$i<count($tmp_bank_record);$i++)
											{
												$tmp_bank_info = explode("|",$tmp_bank_record[$i]);
											?>
												<option value="<?=$tmp_bank_record[$i]?>">[<?=$tmp_bank_info[0]?>]<?=$tmp_bank_info[1]?>(<?=$tmp_bank_info[2]?>)</option>
											<?}?>
											</select>
											</td>
										</tr>
										<tr>
											<td>
											입금자명 : <input type="text" class="ed" style="width:120px;" name="bank_user" value="<?=$member[mb_name]?>">
											</td>
										</tr>
										<tr>
											<td>※<span style="color:#888888;font-size:11px"> 7일이내 미입금시 자동취소됩니다.(단, 토/일/공휴일 제외)</span></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td align="center" height="50">
		<button class="cart_btn1" onclick="order_step3();">다음단계</button>&nbsp;
		<button class="cart_btn1" onclick="location.href='cart.php';">이전단계</button>
		</td>
	</tr>
</form>
</table>
<?
include("$g4[path]/_tail.php");

?>